﻿namespace Digitalmes.Application;

/// <summary>
/// 应用程序返回 Boolean 值结果
/// </summary>
public sealed class BooleanResult
{
    /// <summary>
    /// true/false
    /// </summary>
    public bool Success { get; init; }

    /// <summary>
    /// 错误消息
    /// </summary>
    public string? ErrMessage { get; init; }

    public static BooleanResult Ok()
    {
        return From(true, default);
    }

    public static BooleanResult Error(string? errMessage)
    {
        return From(false, errMessage);
    }

    public static BooleanResult From(bool success, string? errMessage)
    {
        return new BooleanResult
        {
            Success = success,
            ErrMessage = errMessage,
        };
    }
}
